<template>
	<view>

		<view class="wrap-container">
			<view class="warp-input">
				<view class="warp-text">事件单号:</view>
				<u-input v-model="wh_repair_num" :type="type" :border="border" :height="height" :disabled="true" />
			</view>
			<view class="warp-input">
				<view class="warp-text">关联位置:</view>
				<u-input v-model="eq_name" :type="type" :border="border" :height="height" :disabled="true" />
			</view>
			<view class="warp-input">
				<view class="warp-text">执行人:</view>
				<u-input v-model="wh_repair_person" :type="type" :border="border" :height="height" :disabled="true" />
			</view>
			<view class="warp-input">
				<view class="warp-text">申报时间:</view>
				<u-input v-model="wh_declare_time" :type="type" :border="border" :height="height" :disabled="true" />
			</view>

			<view class="warp-input">
				<view class="warp-text"> <span style="color:red">*</span>故障现象:</view>
				<u-input v-model="wh_job_describe" :type="type" :border="border" :height="height" required
					name="wh_job_describe" placeholder="请输入内容" />
			</view>
			<view class="warp-input">
				<view class="warp-text"> <span style="color:red">*</span>维修记录:</view>
				<u-input v-model="wh_repair_result" :type="type" :border="border" :height="height"
					placeholder="请输入内容" />
			</view>
			<view class="warp-input" @click="searchState">
				<view class="warp-text">设备状态:</view>
				<!-- <select mode="single-column" :show-action="false" shape="square" v-model="wh_equipment_status"
					placeholder="请选择状态"></select> -->
				<u-input @click="searchState" v-model="statusname" :type="type" :border="border" :height="height"
					placeholder="请选择设备状态" />
				<u-select v-model="showStates" :list="states" :border="border" :height="height"
					@confirm="confirmState"></u-select>
			</view>
			<!--提交按钮-->
			<view class="button" @click="submit()"><text>确认</text></view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				id: "",
				type: 'text',
				height: 60,
				border: true,
				wh_complete_time: "",
				wh_repair_person: "",
				wh_repair_result: "",
				wh_repair_num: "",
				eq_name: "",
				eq_id: "",
				wh_job_describe: "",
				is_edit: "",
				wh_declare_time: "",
				wh_equipment_status: "",
				repair_person_id: "",
				wh_repair_status: "",
				maintenance_time: "",
				wh_repair_create_time: "",
				wh_job_describe: "",
				tags: [],
				statusname: "",
				states: [{
						value: '2',
						label: '运行'
					},
					{
						value: '3',
						label: '停止'
					},
					{
						value: '1',
						label: '异常'
					},
					{
						value: '4',
						label: '维修维护'
					}

				],
				showStates: false
			}
		},
		created() {
			this.getOderView();
		},
		onLoad(e) {
			this.id = e.id
			// this.id = '908348968876900353'
		},
		onReady() {
			// this.getServerData();
		},
		beforeDestroy() {},
		methods: {
			getOderView() {
				this.$u.api.eqView({
					"algorithmProcessId": "orderById",
					"param": {
						"data": {
							id: this.id,
							organ_uuid: '',
							user_uuid: uni.getStorageSync('uuid')
						}
					}
				}).then(Response => {
					const res = Response.data.data.result.list[0];
					this.wh_complete_time = res.wh_complete_time;
					this.wh_repair_person = res.wh_repair_person;
					this.wh_repair_result = res.wh_repair_result;
					this.wh_repair_num = res.wh_repair_num;
					this.eq_name = res.eq_name;
					this.eq_id = res.eq_id;
					this.is_edit = res.is_edit;
					this.wh_declare_time = res.wh_declare_time;
					this.wh_repair_status = res.wh_repair_status;
					this.repair_person_id = res.repair_person_id;
					this.maintenance_time = res.maintenance_time;
					this.wh_repair_create_time = res.wh_repair_create_time;
					this.wh_job_describe = res.wh_job_describe;
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			confirmState(e) {
				e.map((val, index) => {
					this.statusname = val.label;
					this.wh_equipment_status = val.value;
				})
			},
			searchState() {
				this.showStates = true;
				// if (this.wh_equipment_status.length != 0) {
				// 	this.showStates = false;
				// 	this.wh_equipment_status = '';
				// 	return;
				// }
			},
			submit() {
				if (this.wh_job_describe == null) {
					this.$u.toast('请输入故障现象');
					return;
				}
				if (this.wh_repair_result == null) {
					this.$u.toast('请输入维修记录');
					return;
				}
				this.$u.api.eqView({
					"algorithmProcessId": "update_ordder",
					"param": {
						"data": {
							id: this.id,
							wh_job_describe: this.wh_job_describe,
							wh_repair_result: this.wh_repair_result,
							wh_equipment_status: "3",
							user_id: uni.getStorageSync('uuid')
							// user_id:'1fe003fc-19ce-46af-ab66-48e021759e7c'
						}
					}
				}).then(Response => {
					const res = Response;
					if (res.code == '200') {
						if (res.data.data.status == '406') {
							//提示错误信息
							this.$u.toast(res.data.data.message);

						} else {
							uni.navigateTo({
								url: "/pages/sys/eventwororder/eventorder/eventOrder"
							});
						}
					}

				})
			},
		}
	}
</script>
<style lang="scss">
	@import '../style/common.scss';
</style>